package com.cc.ndmall.config.controller;

import com.cc.ndmall.common.utils.PageUtils;
import com.cc.ndmall.common.utils.R;
import com.cc.ndmall.config.entity.StorageEntity;
import com.cc.ndmall.config.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;




/**
 * 文件存储表
 *
 * @author yaochenzhou
 * @email sunlightcs@gmail.com
 * @date 2020-11-07 10:33:28
 */
@RestController
@RequestMapping("config/storage")
public class StorageController {
    @Autowired
    private StorageService storageService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("config:storage:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = storageService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("config:storage:info")
    public R info(@PathVariable("id") Integer id){
		StorageEntity storage = storageService.getById(id);

        return R.ok().put("storage", storage);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("config:storage:save")
    public R save(@RequestBody StorageEntity storage){
		storageService.save(storage);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("config:storage:update")
    public R update(@RequestBody StorageEntity storage){
		storageService.updateById(storage);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("config:storage:delete")
    public R delete(@RequestBody Integer[] ids){
		storageService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
